<template>
  <d2-container>
    <el-table :data="logList" border style="width: 100%">

      <el-table-column prop="exec_info" label="操作信息"></el-table-column>
      <el-table-column prop="meta_data.ip" label="请求ip"></el-table-column>
      <el-table-column prop="createdAt" label="操作时间"></el-table-column>

    </el-table>
    <el-pagination
            background
            layout="total,sizes,prev, pager, next,jumper"
            :page-size="pageSize"
            :current-page="currentPage"
            :total="total"
            @current-change="handleCurrentChange"
            @size-change="handlerSizeChange"
            @next-click="handleNextPage"
            @prev-click="handlePrevClick"
    ></el-pagination>
  </d2-container>
</template>

<script>
  import request from "@/plugin/axios";

  export default {
    data() {
      return {
        logList: undefined,
        total: 0,
        pageSize: 20,
        currentPage: 1,
      };
    },
    methods: {
      handleCurrentChange(e) {
        this.getLogList(e, this.pageSize);
      },
      handlerSizeChange(e) {
        this.pageSize = e;
        this.getLogList(1, this.pageSize);
      },
      handleNextPage(e) {
        this.getLogList(e, this.pageSize);
      },
      handlePrevClick(e) {
        this.getLogList(e, this.pageSize);
      },
      getLogList(page, pageSize) {
        let data = {};
        (data.page = page), (data.pageSize = pageSize);
        request({
          url: "/log/getLogList",
          method: "post",
          data
        }).then(res => {

          if (res.code == 200) {
            console.log(res.data)
            this.logList = res.data.log;
            this.total = res.data.total;
            // 返回数据
          }

        });
      },
    },
    created() {
      this.getLogList(this.currentPage, this.pageSize);
    }
  }


</script>
